<template>
	<div v-show="show">
		<Row>
			<ICol span="5">
				<ImageGroup ref="group" :callback="groupChoise"></ImageGroup>
			</ICol>
			<ICol span="18" offset="1">
				<ImageList ref="list" :callback="newPic" :choiseBack="choiseBack"></ImageList>
			</ICol>
		</Row>
	</div>
</template>
<script>
	import {Row,Col} from 'view-design';

	import ImageGroup from 'admin/components/wechat/manager/material/image/group';
	import ImageList from './image-list';

	export default{
		components:{
			Row,
            'ICol':Col,
            ImageGroup,
            ImageList
        },
        props :{
            callback:{
                type: Function,
                required : true,
            },
        },
        data(){
        	return {
                show : true,
        		choiseUrl : '',
        	}
        },
        methods :{
            //获取数据
        	init(){
        		this.$refs.group.getGroups();
        		this.$refs.list.getImages();
        	},
            //初始化
        	reset(){
        		this.$refs.group.reset();
                this.$refs.list.reset();	
        	},
            //选中分组
            groupChoise(id){
                this.$refs.list.wechatImageGroupId = id;
                this.$refs.list.page = 1;
                this.$refs.list.getImages();
            },
            //图片上传成功、刷新分组数据量
            newPic(){
                this.$refs.group.getGroups();
            },
            //选中或非选中,获得子选中图片,刷新当前组件选中URL
            choiseBack(){
                this.callback(this.$refs['list'].choiseUrl,this.$refs['list'].choiseImageId);
            }
        }
	}
</script>